import { isEmpty, validaEmpty } from "@/utils/validate";

type Str = string | number | undefined;
export const filterOptionDict = (str: Str, option?: DictFace[]): Str => {
  if (!validaEmpty(str)) return str;
  const data = option && option.find((v: DictFace) => v.code === String(str));
  return data ? data.code : str;
};

interface typeOption {
  label: string;
  value: string | number;
  tagType?: string;
}
export function filterOption(
  val: string | undefined | number,
  option: typeOption[]
): undefined | typeOption {
  if (isEmpty(val) || isEmpty(option)) return;
  return option && option.find((v: any) => v.value == val);
}
